﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Web;

using System.IO;

using WSServer.Interfaces;
using BartonExtension;

namespace WSServer
{
    public class WSStorage : IWSStorage
    {
        public override bool store(List<WSResponse> obj,string storeId)
        {
            var socket_cacheStoragePath = HttpRuntime.AppDomainAppPath + "socket_cache\\";
            if(!Directory.Exists(socket_cacheStoragePath))
            {
                Directory.CreateDirectory(socket_cacheStoragePath);    
            }
            SerializeManager.SerializeToFile(obj, socket_cacheStoragePath + storeId + ".socketcache");
            return false;
        }

        public override List<WSResponse> loadFromStorage(string storeId)
        {
            var socket_cacheStoragePath = HttpRuntime.AppDomainAppPath + "socket_cache\\";
            return SerializeManager.DeserializeFromFile<List<WSResponse>>(socket_cacheStoragePath + storeId + ".socketcache");
        }
    }
}
